#/bin/bash

#/usr/local/redis-cluster/9000/

log_path="/usr/local/log/"
data_path="/usr/local/redis-cluster/"
config_path="/root/tool"
redis_path="/root/tool/redis"

if [ ! -d "${log_path}" ]; then
  mkdir "${log_path}" -p
  echo "int redis log dir:${log_path}"
fi

if [ ! -d "${data_path}" ]; then
  mkdir "${data_path}/9000/" -p
  mkdir "${data_path}/9001/" -p
  mkdir "${data_path}/9002/" -p
  mkdir "${data_path}/9003/" -p
  mkdir "${data_path}/9004/" -p
  mkdir "${data_path}/9005/" -p
  mkdir "${data_path}/9006/" -p
  mkdir "${data_path}/9007/" -p
  echo "int redis redis-cluster dir:${log_path}"
fi

case ${1} in

"start")
  ${redis_path}/src/redis-server ${config_path}/config/node-9000.conf
  ${redis_path}/src/redis-server ${config_path}/config/node-9001.conf
  ${redis_path}/src/redis-server ${config_path}/config/node-9002.conf
  ${redis_path}/src/redis-server ${config_path}/config/node-9003.conf
  ${redis_path}/src/redis-server ${config_path}/config/node-9004.conf
  ${redis_path}/src/redis-server ${config_path}/config/node-9005.conf
  ;;
"stop")
  pkill redis-server
  ;;
esac
